
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

public class Main {
	
	private static final int sleepTime = 200;
	
	private static DataInputStream dis = null;
	private static DataOutputStream dos = null;
	
	private static int state = State.READY;
	
	public static void main(String[] args) {
		
		Controller controller = new Controller();
		ConnectorPC connector = new ConnectorPC();
		
		if (!connector.connect("")) {
			System.out.println("Could not connect");
			System.exit(-1);
		}
		
		dis = connector.getDIS();
		dos = connector.getDOS();
		
		//send commands over bluetooth
		while(true) {
			try {
				dos.writeInt(controller.getDirectionCommand());
				dos.flush();
			}
			catch(IOException ex) {
				System.out.println("direction writing error");
				System.exit(-1);
			}
			
			//reset the direction command
			controller.resetDirectionCommand();
			
			try {
				state = dis.readInt();
			}
			catch(IOException ex) {
				System.out.println("state reading error");
				System.exit(-1);
			}
		}
		
	}

}
